package pierwszy;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.events.AbstractWebDriverEventListener;

public class MyEventListener extends AbstractWebDriverEventListener {
	
	//Navigate to related methods
	@Override
	public void beforeNavigateTo (String url, WebDriver driver) {
		System.out.println("Before Navigate to : " + url + " and Current url is: " + driver.getCurrentUrl());
	}
	
	@Override
	public void afterNavigateTo(String url, WebDriver driver) {
		System.out.println("After Navigate to : " + url + " and Current url is: " + driver.getCurrentUrl());
	}
	
	//Navigate back related methods
	@Override
	public void beforeNavigateBack(WebDriver driver) {
		System.out.println("Before navigate back. Right now I'm at " + driver.getCurrentUrl());
	}
	
	@Override
	public void afterNavigateBack(WebDriver driver) {
		System.out.println("After navigate back. Right now I'm at " + driver.getCurrentUrl());
	}
	
	//Navigate forward related methods
	@Override
	public void beforeNavigateForward(WebDriver driver) {
		System.out.println("Before navigate forward. Right now I'm at " + driver.getCurrentUrl());
	}
	
	@Override
	public void afterNavigateForward(WebDriver driver) {
		System.out.println("After navigate forward. Right now I'm at " + driver.getCurrentUrl());
	}	
	
	//Find by related methods
	@Override
	public void beforeFindBy(By by, WebElement element, WebDriver driver) {
		System.out.println("Before find following element " + driver.toString());
	}
	
	@Override
	public void afterFindBy(By by, WebElement element, WebDriver driver) {
		System.out.println("After find following element " + driver.toString());
	}
	
	//Click on related events
	@Override
	public void beforeClickOn(WebElement element, WebDriver driver) {
		System.out.println("Before click on following element " + driver.toString());
	}
	
	@Override
	public void afterClickOn(WebElement element, WebDriver driver) {
		System.out.println("After click on following element " + driver.toString());
	}
	
	//Change of value related methods
	@Override
	public void beforeChangeValueOf(WebElement element, WebDriver driver) {
		System.out.println("Before change value of following element " + driver.toString());
	}
	
	@Override
	public void afterChangeValueOf(WebElement element, WebDriver driver) {
		System.out.println("After change value of following element " + driver.toString());
	}
	
	//Exception related methods
	@Override
	public void onException(Throwable throwable, WebDriver driver) {
		System.out.println("After throw of folloing exception " + throwable.getMessage());
	}
	
	//Change of value related methods
	@Override
	public void beforeScript(String script, WebDriver driver) {
		System.out.println("Before execution of script.");
	}
	
	@Override
	public void afterScript(String script, WebDriver driver) {
		System.out.println("After execution of script");
	}
	
	
}
